package API.DAY9.thread;

public class SyncDemo3 {
    public static void main(String[] args) {
        foo f1 = new foo();
        foo f2 = new foo();
        new Thread(()->f1.doSome()).start();
        new Thread(()->f2.doSome()).start();

        new Thread(foo::doSome).start();
        new Thread(foo::doSome).start();
    }
}
class foo {
    public static synchronized void doSome(){
        synchronized (foo.class) {
            try {
                Thread t = new Thread();
                System.out.println(t.getName() + "开始...");
                Thread.sleep(5000);
                System.out.println(t.getName() + "结束...");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}